/* wod.t   WORK ORDER DELETE TRIGGER                                          */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.1.1.1 $                                                           */
/*V8:ConvertMode=NoConvert                                                    */
/* Revision: 1.1       BY: Julie Milligan       DATE: 05/13/02   ECO: *P06V*  */
/* $Revision: 1.1.1.1 $      BY: Inna Fox             DATE: 06/13/02   ECO: *P04Z*  */
/******************************************************************************/

TRIGGER PROCEDURE FOR DELETE OF wo_mstr.

/*fdn*/    {mfdeclre.i }
/*fdn*/    define new shared work-table wf_old_wo_mstr like wo_mstr.

/* Remove any flow schedule details associated with current work order */
for first flsd_det exclusive-lock where
   flsd_flow_wo_nbr = wo_nbr and
   flsd_flow_wo_lot = wo_lot: end.
if available flsd_det then delete flsd_det.

HK:
do:
    if can-find(first dt_mstr where dt_table = "wo_mstr" and dt_type = "SYNC") then
        run CreateSyncFlag(input "DEL", input recid(wo_mstr), input "wo_mstr").

    if not can-find ( first dt_mstr where dt_table = "wo_mstr" and dt_type = "DEL" ) then leave HK.
    
    if not can-find ( first wf_old_wo_mstr ) then do:
        create wf_old_wo_mstr.
        if recid(wf_old_wo_mstr)= -1 then .
    end.
    
    buffer-copy wo_mstr to wf_old_wo_mstr no-error.

    for first dt_mstr no-lock where dt_table = "wo_mstr" and dt_type = "DEL" :
    
        run CreateDthist(input dt_table, input dt_field, input dt_type, input "", input "", 
            input recid(wo_mstr), input wo_mstr.wo_nbr, input wo_mstr.wo_lot, input wo_mstr.wo_part, input "",
            input "", input "", input "", input "") .
            
    end.
end.

{hkdttrans.i}
